package org.xg.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.xg.domain.RoleVO;
import org.xg.domain.User2RoleVO;

import com.googlecode.genericdao.search.Search;

@Repository
public class User2RoleDao extends BaseDao<User2RoleVO, String> {

	/**
	 * 查找用户对应的角色
	 * @param username
	 * @return
	 */
	public List<RoleVO> findRolesByUsername(String username){
		Search s = new Search();
		s.addField("role");
		s.addFilterEqual("user.username", username);
		return this.search(s);
	}
	
	/**
	 * 查找用户对应的角色
	 * @param username
	 * @return
	 */
	public List<RoleVO> findRolesByUserid(String id){
		Search s = new Search();
		s.addField("role");
		s.addFilterEqual("user.id", id);
		return this.search(s);
	}
}
